package 代码记录.指定公司代码练习记录.西安.分值200分;

import java.util.*;

/**
 * @author zx
 * @create 2023-07-09 22:04
 * 参考人家的思路
 */
public class 叠放书籍 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] arr = str.split(",");
        for(int i = 0;i < arr.length;i++){
            String temp = "";
            for(int j = 0;j < arr[i].length();j++){
                if(arr[i].charAt(j) >= '0' && arr[i].charAt(j) <= '9'){
                    temp += arr[i].charAt(j);
                }
            }
            arr[i] = temp;
        }
        List<int[]> list = new ArrayList<>();
        for(int i = 0,j = 0;i < arr.length;i += 2,j++){
            int[] num = new int[2];
            num[0] = Integer.parseInt(arr[i]);
            num[1] = Integer.parseInt(arr[i + 1]);
            list.add(num);
        }
        list.sort(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return (o1[0] < o2[0] || (o1[0] == o2[0] && o1[1] < o2[1])) ? 1 : -1;//注意这里
            }
        });
        int minL = list.get(0)[0];
        int minW = list.get(0)[1];
        int res = 1;

        int i = 1;
        while (i < list.size()) {
            int[] cur = list.get(i);
            int l = cur[0];
            int w = cur[1];
            if (minL > l && minW > w) {
                minL = l;
                minW = w;
                res++;
            }
            i++;
        }
        System.out.println(res);
    }
}
